//
//  RootNavigationController.m
//  FlowerRainGarden
//
//  Created by 阿仁欧巴 on 16/4/15.
//  Copyright © 2016年 aren. All rights reserved.
//

#import "RootNavigationController.h"


@implementation RootNavigationController


+ (void)initialize
{
                             
    UINavigationBar *bar2 = [UINavigationBar appearanceWhenContainedInInstancesOfClasses:@[([self class])]];
    [bar2 setBackgroundImage:[UIImage imageNamed:@"navigationbarBackgroundWhite"] forBarMetrics:UIBarMetricsDefault];
    NSLog(@"dddddd");

}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.navigationBar.tintColor = [UIColor blackColor];
    self.navigationController.navigationBar.translucent = NO;

}





- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if (self.childViewControllers.count > 0) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button setTitle:@"返回" forState:UIControlStateNormal];
        [button setImage:[UIImage imageNamed:@"navigationButtonReturn"] forState:UIControlStateNormal];
        [button setImage:[UIImage imageNamed:@"navigationButtonReturnClick"] forState:UIControlStateHighlighted];
        button.size = CGSizeMake(60, 30);
        
        //button内部的所有内容左对齐
        button.contentEdgeInsets = UIEdgeInsetsMake(0, -10, 0, 0);//button里面的内容向左偏移10；
        button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        //        button.backgroundColor = [UIColor blueColor];
        [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [button setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted];
        [button addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
        viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
        viewController.hidesBottomBarWhenPushed = YES;
    }
    
    [super pushViewController:viewController animated:animated];
    
}

- (void)back
{
    [self popViewControllerAnimated:YES];
}









@end
